<template>
  <div class="wrapper" ref="wrapper">
    <div class="content">
        <slot></slot>
    </div>
  </div>
</template>

<script>
import BSroll from 'better-scroll'
export default {
    data() {
        return {
            scroll:null
        }
    },
    props:{
        probeType:{
            type:Number,
            default:0
        },
        pullUpLoad:{
            type:Boolean,
            default:false
        }
    },
    mounted() {
        this.scroll = new BSroll(this.$refs.wrapper,{
            probeType:this.probeType,
            observeDOM:true,
            click:true,
            pullUpLoad:this.pullUpLoad
        })
        this.scroll.on('scroll',position=>{
            this.$emit("scroll",position)
            
        })
        if(this.pullUpLoad){
            this.scroll.on('pullingUp',()=>{
                this.$emit("pullingUp")
                
            })
        }
       
    },
    methods: {
        scrollTo(x,y,time = 1000){
            this.scroll && this.scroll.scrollTo(x,y,time)
        },
        refresh(){ 
            this.scroll && this.scroll.refresh()
        },
        finishpullup(){
            this.scroll && this.scroll.finishPullUp()
        }
    },
}
</script>

<style scoped>

</style>